package cn.ainit.base.approve;

import java.util.List;

import javax.servlet.http.HttpSession;

import cn.ainit.base.approve.entity.SysApprove;
import cn.ainit.common.ReturnObject;

public interface ApproveService {
	/**
	 * 根据单据ID得到所有的数据
	 * @return
	 * @throws Exception
	 */
	List<SysApprove> listApproves(String djId) throws Exception;
	/**
	 * 
	 * @param sql
	 * @return
	 * @throws Exception
	 * @author wyang
	 * @date : 2014-1-20 下午06:11:19
	 */
	boolean updApprove(String sql) throws Exception;
	/**
	 * 根据单据ID和单据等级查找这条数据
	 * @param djId
	 * @param djLevel
	 * @return
	 * @throws Exception
	 * @author wyang
	 * @date : 2014-1-24 上午09:39:35
	 */
	SysApprove getOneApprove(String djId,Integer djLevel) throws Exception;
	/**
	 * 得到原表
	 * @param cost
	 * @return
	 * @throws Exception
	 * @author wyang
	 * @date : 2014-1-24 上午09:57:20
	 */
	String getApproveTable(String type) throws Exception;
	/**
	 * 根据sql返回一个string
	 * @param sql
	 * @return
	 * @throws Exception
	 * @author wyang
	 * @date : 2014-1-24 上午11:05:13
	 */
	String getValue(String sql) throws Exception;
	
	/**
	 * 审批示根据ds_id 得到ds_name
	 * @param sql
	 * @return
	 * author:cff
	 * date:2014/3/29 11:09
	 * @throws Exception
	 */
	public String getDsName(String dsId) throws Exception;
	 
	
	/**
	 * 根据单据ID和单据等级,单据的类型查找这条数据
	 * @param djId
	 * @param djLevel
	 * @return
	 * @throws Exception
	 * @author cff
	 * @date : 2014-4-10 上午10:15:35
	 */
	public SysApprove getApproveByPks(String djId, String djLevel, String djType) throws Exception;
	
	
	/**
	 * 根据djId查询到最高的单据等级
	 * @param djId
	 * @return
	 * author:cff
	 */
	public Integer maxDjLevel(SysApprove sysApprove) throws Exception;
	
	/***
	 * 根据djId查询到最低的单据等级
	 * @param djId
	 * @return
	 * author:cff
	 */
	public Integer minDjLevel(String djId)throws Exception;
	

	/***
	 * 根据单据Id跟新全部的审批状态(驳回全部时所有的该单据的审批数据都为2未通过)
	 * @param djId
	 * @return
	 * author:cff
	 */
	public Integer  upAllApplyByDjId(String djId) throws Exception;
	
	/***
	 * 根据单据Id，单据的等级跟新部分的审批状态(驳回上一级时)
	 * @param djId
	 * @return
	 * author:cff
	 */
	public Integer  upApplyByIdLevel(String djId,String djLevel) throws Exception;
	

	/***
	 * 将单据的相关参数传入 确保 审批表有数据
	 * @param djId
	 * @param djLevel
	 * @param djType
	 * @return
	 * @throws Exception
	 */
	public String getApprove(String djId, String djLevel, String djType) throws Exception;
	
	
	/***
	 * 很据djType得到dj的主键
	 * @param djType
	 * @return
	 * @throws Exception
	 */
	public String getPKByDjType(String djType)throws Exception ;
			
	/**
	 * 根据Id得到审批表中的数据
	 * @param id
	 * @return
	 * @throws Exception
	 * @author wyang
	 * @date : 2014-4-30 下午04:23:49
	 */
	public List<SysApprove> dataById(String id,String dsId) throws Exception;
	
	

	/******
	 * 根据单据的dsId 得到单据的最高的审批级别
	 * @param dsId
	 * @return
	 * @throws Exception
	 */
	public String  getMaxApplyLevelByDsId(String dsId,String param1) throws Exception;
	
	/****
	 * 调用存储过程生成单据approveList数据
	 * @param djId
	 * @param dsId
	 * @param djType
	 * @param djCode
	 * @return
	 * @throws Exception
	 */
	public ReturnObject produceApproveList(String djId,String dsId,String djType,String djCode,HttpSession session) throws Exception;
	
	/****
	 * 根据审批级别和审批单据的dsId得到审批人的外键
	 * @param level
	 * @param dsId
	 * @param param
	 * @return
	 * @throws Exception
	 */
	public String getExamineManFkVal(Integer level,String dsId,String param) throws Exception;
	
	
	/***
	 * 根据审批人的外键值得到审批人的编码的集合
	 * @param sql
	 * @return
	 * @throws Exception
	 */
	public List getItemsCodes (String sql) throws Exception;
	/**
	 * 确定审批过程
	 * @param approveReceive
	 * @return
	 * @throws Exception
	 */
	Boolean sureSaveAppr(SysApprove sysApprove,HttpSession session) throws Exception;
	
	/****
	 * 根据djid和指定的等级得到该等级的审批结果
	 * @param level
	 * @param djId
	 * @param string
	 * @return
	 */
	public String checkApprovePass(Integer level,String dsId, String djId,String param)  throws Exception;
	

	/***
	 * 修改审核日期，审核人，审核时间
	 * @param sqlText
	 * @param valuesArr
	 * @param whereValue
	 * @return
	 */
	boolean updateDjVerify (String table, String pkName,String pkVal,HttpSession session) throws Exception;
	
	
	/*****
	 * 	确认审批的之后调用的存储过程，生成信息的消息提示
	 * @return
	 */
	boolean sureApproveShowMsg(String djId,Integer approveLevel,String dsId,HttpSession session) throws Exception;
	
	/****
	 * 得到最低的等级的审批对象
	 * @param djId
	 * @return
	 * @throws Exception
	 * @author chenfeifei
	 * @version 创建时间：2014-10-20 上午09:06:31
	 */
	public SysApprove getMinLevelAppObj(String djId,String dsId) throws Exception;
	
	//更新is_verify
	public ReturnObject  updateIsVerify(Integer approveLevel,String djId,String dsId,HttpSession session) throws Exception ;
	
	public String delApproveFlow(String regId, Integer curLevel, String flowId) throws Exception;
	
	/***
	 * 判断当前登录人是否具备审批权限
	 * @author chenfeifei
	 * @version 创建时间：2014-12-5 下午03:41:52
	 */
	Integer getIsApproveRight(String soureId, String djId, String dsId,HttpSession session) throws Exception;
	
	
	/***
	 * 最高一级的领导审批通过之后确认驳回
	 * @param session
	 * @return
	 * @author feifei
	 * @date: 2015-3-31 下午04:32:28 
	 */
	public ReturnObject sureRejectByLead(String djId,String dsId,String code,HttpSession session) throws Exception;
	
	/***
	 * 根据dsid判断单据是否有审批
	 * @param dsId
	 * @param param
	 * @return
	 * @throws Exception
	 * @author feifei
	 * @date: 2015-4-2 上午11:15:08 
	 */
	public String isRejectByDsId(String dsId,String param) throws Exception;
	
	/***
	 * 验证数据的完成性
	 * @param djId
	 * @param dsId
	 * @param prams
	 * @return
	 * @throws Exception
	 * @author feifei
	 * @date: 2015-4-9 下午06:11:45 
	 */
	public String checkSubmitData(String djId, String dsId, String prams,HttpSession session) throws Exception;
			
	/***
	 * 根据当前登陆人判断是不是总裁
	 * @param djId
	 * @param dsId
	 * @param session
	 * @return
	 * @throws Exception
	 * @author feifei
	 * @date: 2015-4-13 下午05:56:51 
	 */
	public String getMaster(String djId,String dsId,HttpSession session) throws Exception;
	 
}
